package com.sky.controller.user;

import com.sky.entity.Category;
import com.sky.result.Result;
import com.sky.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user/category")
public class UserCategoryContorller {
    @Autowired
    private CategoryService categoryService;
    @GetMapping("/list")
    public Result getListByType(@RequestParam(required = false) Integer type){
        List<Category> category=null;
        if(type==null){
            category=categoryService.getList();
        }else{
            category=categoryService.getByType(type);
        }

        return Result.success(category);
    }
}
